<template>
    <div class="SelfSet">
        <hb-title :title="Lang.setTitle[lang]" />

        <!-- <hb-box class="hbbox"
            :title="Lang.setPwd[lang][0]">
            <c-set :setTitle='Lang.setPwd[lang][1]'
                :doset='Lang.setPwd[lang][2]'
                :gopath="List[0]" />
        </hb-box> -->
        <!-- <hb-box class="hbbox"
            :title="Lang.setPhone[lang][0]">
            <c-set :setTitle='Lang.setPhone[lang][1]'
                :doset='Lang.setPhone[lang][2]'
                :gopath="List[1]" />
        </hb-box> -->
        <hb-box class="hbbox" :title="Lang.bindCard[lang][0]">
			<!--<c-set v-for="(bank,i) in bankCard" :key="i" :setTitle='bank.banhNumber' :id='bank.bankId' :type='1' :doset='Lang.status[lang][0]' gopath="selfset"  @update="update"/>-->
            <!--<c-set setTitle='-&#45;&#45;' :doset='Lang.bindCard[lang][2]' :gopath="List[2]" />-->
			<c-set v-for="(bank,i) in bankCard" :key="i" :setTitle='bank.banhNumber' :id='bank.bankId' :type='1' gopath="selfset"/>
            <c-set setTitle='---' :doset='Lang.bindCard[lang][2]' :gopath="List[2]" />
		</hb-box>
		<hb-box class="hbbox" :title="Lang.bindwechat[lang][0]">
			<c-set v-for="(wechat,i) in Wechat" :key="i" :setTitle='wechat.account' :id='wechat.id' :type='2'  gopath="selfset"/>
            <c-set setTitle='---' :doset='Lang.bindCard[lang][2]' :gopath="List[3]" />
		</hb-box>
		<hb-box class="hbbox" :title="Lang.bindzhifubao[lang][0]">
			 <c-set v-for="(al,i) in alipay" :key="i" :setTitle='al.account' :id='al.id' :type='2' gopath="selfset"/>
            <c-set setTitle='---' :doset='Lang.bindCard[lang][2]' :gopath="List[4]" />
		</hb-box>
		<hb-dialog v-if="msgback !== ''">
			<span v-text="msgback"/>
		</hb-dialog>
    </div>
</template>

<script>
import Lang from './lang.js'
import CSet from './set/a'
import {vpost, vlink} from '@api'
export default {
	name: 'selfset',
	data() {
		return {
			Lang,
			phone: '',
			alipay: [],
			Wechat: [],
			bankCard: [],
			msgback: '',
			List: [
				'safe/change',
				'selfset/changephone',
				'selfset/bindcard',
				'selfset/bindwechat',
				'selfset/bindzhifubao',
			],
		}
	},
	created() {
		this.init()
	},
	computed: {
		lang() {
			return this.$store.state.setting.lang
		},
	},
	methods: {
		init() {
			let inputdate={
				id : this.$store.state.user.uid,
			}
			vpost(vlink.user.walletInf,inputdate).then(re => {

				if (re.status == 1) {
					console.log('银行',re.data)
					// this.bankCard = re.data.bank
					let objBank = {
						banhNumber:re.data.bank
					}
					this.bankCard.push(objBank)
					let objWeChat = {
						account:re.data.wx
					}
					this.Wechat.push(objWeChat)
					let objAliPay = {
						account:re.data.zfb
					}
					this.alipay.push(objAliPay)
				} else {
					if (re != null && re !== undefined) {
						this.msgback = re.msg
					}
					// //退出重新登录
					// setTimeout(() => {
					// 	this.msgback = ''
					// 	sessionStorage.clear()
					// 	this.$router.push('/')
					// 	location.reload()
					// }, 1300)
				}
			})
		},
		//更新账号的状态 (删除)
		update(id, type) {
			let inputdate = {
				id: id,
				type: type,
			}
			vpost(vlink.user.deleteWall, inputdate).then(re => {
				if (re.status == 1) {
					this.msgback = re.msg
					this.init()
				} else {
					this.msgback = this.Lang.status[this.lang][3]
				}
				this.closeMsg()
			})
		},
		closeMsg() {
			setTimeout(() => {
				this.msgback = ''
			}, 1300)
		},
	},
	components: {
		'c-set': CSet,
	},
}
</script>

<style scoped>
.SelfSet {
	margin: 40px auto;
	width: 1200px;
}
.hbbox {
	margin-bottom: 20px;
}
</style>
